﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace webapp4U.UI
{
    public partial class WebMaster_Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void btSave_Click(object sender, EventArgs e)
        {

            // kiem tra email da co chua
            if (webapp4U.BOL.NewsLetter.CheckEmail(txtEmail.Text) == false)
            {
                webapp4U.BOL.NewsLetter obj = new webapp4U.BOL.NewsLetter();
                obj.Email = txtEmail.Text;
                obj.AddedDate = DateTime.Now;
                obj.FirstName = txtFirstName.Text;
                obj.LastName = txtLastName.Text;
                webapp4U.BOL.NewsLetter.Insert(obj);

                lblMsg.CssClass = "lblMsg";
                lblMsg.Text = "Cập nhật thông tin thành công";
                txtEmail.Text = "";
                txtFirstName.Text = "";
                txtLastName.Text = "";
            }
            else
            {
                lblMsg.CssClass = "Error";
                lblMsg.Text = "Địa chỉ email này đã có trong danh sách";
            }

            PanelMsg.Visible = true;
        }
    }
}